// components/Recruicoop/Recruicoop.js
const {
  request
} = require("../../utils/index.js")
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item:Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    recruitId:"",
  },
  ready(){
    this.setData({
      recruitId:this.data.item.recruitId
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    //招聘点赞增加
    zpdianzan:async function(e){
      let param={
       url:"hw/portal/user/praise/save",
       header:{
        'content-type': 'application/x-www-form-urlencoded', // 默认值
       },
       data:{
        "token":wx.getStorageSync('token'),
        "praiseModule":"recruit_cooperate",
        "objId":this.data.recruitId,
       },
       method:"POST"
      }
      let res=await request(param);
      if(res.status==100){
        this.setData({
          "item.isPraise":!this.data.item.isPraise
        })
      }
    },
    //招聘点赞取消
    zpcanceldianzan:async function(){
      let param={
        url:"hw/portal/user/praise/del",
        header:{
         'content-type': 'application/x-www-form-urlencoded', // 默认值
        },
        data:{
         "token":wx.getStorageSync('token'),
         "praiseModule":"recruit_cooperate",
         "objId":this.data.item.recruitId,     //当前用户id
        },
        method:"POST"
       }
       let res=await request(param);
       if(res.status==100){
         this.setData({
           "item.isPraise":!this.data.item.isPraise
         })
       }
    },
    //查看
    look: function (option) {
      wx.navigateTo({
        url: '../recruidetail/recruidetail?recruitId='+this.data.recruitId,
      })
    },
  }
})